/*--------------------------------------------------------------------------
  Project::HEXAGON FLIGHT SIMULATOR
  Package::Input
  Class::Mouse
  File Mouse.h
  --------------------------------------------------------------------------
  * METHODS AND CLASS PARAMETERS


  --------------------------------------------------------------------------
  * FUNCTIONS DESCRIPTION
  
  --------------------------------------------------------------------------
  * COPYRIGHT

  --------------------------------------------------------------------------
  * INFO ABOUT AUTHOR AND VERSIONS
  Author:	Tino Giorgio	Data: 
  Rev1:			Data:

  --------------------------------------------------------------------------
  * E-MAIL & CONTACTS

  GIORGIO TINO:	tinoshi@libero.it
	           	shapeofangels@hotmail.com
	            giorgio.tino@studenti.polito.it

  --------------------------------------------------------------------------*/

#if !defined(MOUSE_H)
#define MOUSE_H

#if _MSC_VER > 1000
#pragma once
#endif // _MSC_VER > 1000

#include <stdio.h>
#include <stdlib.h>

#ifdef FREEGLUT_IS_PRESENT
#  include <GL/freeglut.h>
#else
#  ifdef __APPLE__
#    include <GLUT/glut.h>
#  else
#    include <GL/glut.h>
#  endif
#endif

/* Standard includes */
#include <plib/ul.h>
#include <plib/pw.h>
#include <plib/sg.h>
#include <plib/ssg.h>

#include "Defines.h"
#include "Camera.h"

#define FUNC2(x,y) x##y
#define FUNC1(x,y) FUNC2(x,y)
#define FUNC(x) FUNC1(x,__LINE__)

/* DEFINES */
#define MOUSE_LEFT	0x1
#define MOUSE_RIGHT	0x2
#define MOUSE_UP	0x4
#define MOUSE_DOWN	0x8

#define MOUSE_BUTTON_LEFT   0x1
#define MOUSE_BUTTON_RIGHT  0x2
#define MOUSE_BUTTON_CENTER 0x4

#define MOUSE_X 0
#define MOUSE_Y 1


class Mouse  
{
public:
	Mouse();
	virtual ~Mouse();

	void locatePointer(int x, int y);
	void readButtons(int button, int updn, int x, int y);

	int isDirection(int direction);
	int isPressed(int button);

	int isWorking();
	
	void clear();

	sgdLineSegment3* unproject(int x, int y, Camera *c);

private:
	// old mouse position, used to know if mouse is going up
	// or down, left or right.
	int oldPosition[2];
	// delta movement, from the previous call
	int deltaPosition[2];
	// ONE HOT direction
	int direction;
	// ONE HOT for buttons
	int buttons;
};

#endif // !defined(MOUSE_H)
